<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>中心医院医疗服务系统</title>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>

<style>
	* {
		font-size: 12px;
	}
	
	.lmb-hc-item{
		margin-top: 5px;
	}
</style>
<script src="<c:url value="/js/jquery-migrate-1.1.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/jquery.jqprint-0.3.js"/>"></script>
<script type="text/javascript">
	//获取当前登录用户的id
	var  shenpi_staffId = $("#tontyiStaffId").html();
	//查找出需要当前用户审批的采购计划
	$("#tb_lmbhclysp").datagrid({
		url: "to_queryHclysp",
		queryParams:{
			spr: shenpi_staffId,
			page:1, 
			rows:10			
		}
	});



//日期转换
$(function(){
	function lmb_todate_hcly_sp(value){
	    if(value){
			var date = new Date(value);  
	        return date.toLocaleDateString();
		}
	}

	
	//加字段（备注，出库状态,审批时间）
	$("#lmb_hc_ly_sp-add").linkbutton({onClick: function(){
		var rows = $("#tb_lmbhclysp").datagrid("getSelections");
		if(rows.length == 1){	  
			$('#lmb-hc_ly_sp-win').window("open");
			var collarId = rows[0].collarId;
			$.getJSON("to_queryHclyById", {"collarId": collarId}, function(data){
				$("#lmb-hclysp-lydbh").linkbutton({text: data.collarId});
				$("#lmb-hclysp-lylx").linkbutton({text: data.collarType});
				$("#lmb-hclysp-lydx").linkbutton({text: data.collarObjectName});
				$("#lmb-hclysp-lyrq").linkbutton({text: lmb_todate_hcly_sp(data.collarDate)});
				$("#lmb-hclysp-lyck").linkbutton({text: data.collarStorehouseName});
				$("#lmb-hclysp-spr").linkbutton({text: data.collarApprovepeopleName});						
			});	
			
			 //根据id查看详情	
			 $("#lmb-hclysp-dg").datagrid({
				url:'to_queryHclyxq',
				width: '100%',
				queryParams:{					
					collarId: collarId,
	    			page:1, 
	    			rows:10
				}
			});
		}else{
			$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
		}
	}});
	
	$("#lmb—hclysp-btn-ok").linkbutton({onClick: function(){
		$.messager.prompt("提示", "备注", function(v){
			if(v){
				jg ='已通过';
				var rows = $("#tb_lmbhclysp").datagrid("getSelections");
				var collarId = rows[0].collarId;
							
				$("#lmb-hc_ly_sp-form").form("submit", {
					url:'to_hclyshenpi',
					queryParams:{
						collarId:collarId,
						jg:jg,
						bz:v
					},
					success: function(v){
						$.messager.alert('提示', "审批成功！");
						//关闭窗口
						$('#lmb-hc_ly_sp-win').window('close');
						//重新加载数据lmb_hcx
						$("#tb_lmbhclysp").datagrid("reload");	
					}				
				});
			}
		});
		
	}});
	
	$("#lmb—hclysp-btn-false").linkbutton({onClick: function(){
		$.messager.prompt("提示", "备注", function(v){
			if(v){
				jg ='未通过';
				var rows = $("#tb_lmbhclysp").datagrid("getSelections");
				var collarId = rows[0].collarId;
				
			
				$("#lmb-hc_ly_sp-form").form("submit", {
					url:'to_hclyshenpi',
					queryParams:{
						collarId:collarId,
						jg:jg,
						bz:v
					},
					success: function(v){
						$.messager.alert('提示', "审批成功！");
						//关闭窗口
						$('#lmb-hc_ly_sp-win').window('close');
						//重新加载数据
						$("#tb_lmbhclysp").datagrid("reload");	
					}				
				});
			}
		});		
	}});
	
	//查找已审批的领用单
	 $("#lmb_hc_ly_sp-ysp").linkbutton({onClick: function(){
		 $("#tb_lmbhclysp").datagrid({
				url:'to_queryHclyYsp',
				method:'post',
				queryParams:{
					spr:shenpi_staffId,
			    	page:1, 
			    	rows:10
				}
			});
	 	}
	});	
	
	//查找待审批的领用单
	 $("#lmb_hc_ly_sp-dsp").linkbutton({onClick: function(){
		 $("#tb_lmbhclysp").datagrid({
				url:'to_queryHclysp',
				method:'post',
				queryParams:{
					spr:shenpi_staffId,
			    	page:1, 
			    	rows:5
				}
			});
	 	}
	});	
	
	//日期转换
	function lmb_todate_ly_sp(value){
        if(value){
			var date = new Date(value);  
            return date.toLocaleDateString();
		}
    }
	
	 $("#lmb_hc_ly_sp-xq").linkbutton({onClick: function(){
			var rows = $("#tb_lmbhclysp").datagrid("getSelections");
			if(rows.length == 1){	  				
				$('#lmb-hclyspDet-window').window("open");	
				var collarId = rows[0].collarId;
				$.getJSON("toLmbqueryCollar", {"collarId": collarId}, function(data){
					$("#lmb-hclyspDet-lybh").linkbutton({text: data.collarId});
					$("#lmb-hclyspDet-lyrq").linkbutton({text: lmb_todate_ly_sp(data.collarDate)});
					$("#lmb-hclyspDet-lydx").linkbutton({text: data.collarObjectName});
					$("#lmb-hclyspDet-lyck").linkbutton({text: data.collarStorehouseName});
					$("#lmb-hclyspDet-spr").linkbutton({text: data.collarApprovepeopleName});
					$("#lmb-hclyspDet-spsj").linkbutton({text:lmb_todate_ly_sp(data.collarApprovedate)});
					$("#lmb-hclyspDet-spzt").linkbutton({text: data.collarState});
					$("#lmb-hclyspDet-lyzt").linkbutton({text: data.collarCkstatus});
				});	
				
				 //根据id查看详情	
				$("#lmb-hclyspDet").datagrid({
					url:'toLmbqueryLyByLyId',
					method:'post',
					queryParams:{
						collarId:collarId
					}
				
				});
				 
			}else{
				$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
			}
		}});
		//<!-- lmb-hclyDet-print,lmb-hclyDet-window -->
		//点击按钮打印
		$("#lmb-hclyspDet-print").linkbutton({
			onClick: function(){
				$("#lmb-hclyspDet-printArea").jqprint();								
			}			
		});
});
	
</script>
<table id="tb_lmbhclysp" class="easyui-datagrid" 
		data-options="	
			url:'to_queryHclysp',	
			fitColumns:true,fit:true,
			pagination: true,
			pageSize: 5,
			pageList: [5, 10, 15, 20],
			rownumbers: true,
			toolbar: '#tb_lmb_hc_yl_sp',
			border:false
			">
		<thead>
			<tr>	
				<th data-options="field:'',checkbox:true"></th>	
				<th data-options="field:'collarId',width:'20%'">领用单号</th>								
				<th data-options="field:'collarObjectName',width:'15%'">领用对象</th>
				<th data-options="field:'collarStorehouseName',width:'15%'">仓库</th>
				<th data-options="field:'collarDate',width:'14%',
					formatter:function(value){
						if(value){
							var date = new Date(value);  
                            return date.toLocaleDateString();
						}                             
				}">领用申请时间</th>
				<th data-options="field:'collarState',width:'13%'">审批状态</th>
				<th data-options="field:'collarApproveresult',width:'13%'">审批结果</th>
				<th data-options="field:'collarCkstatus',width:'13%'">领用状态</th>
				<th data-options="field:'collarBeizhu',width:'16%'">备注</th>
			</tr>
		</thead>
	</table>
	
	<div id="tb_lmb_hc_yl_sp">
		<a id="lmb_hc_ly_sp-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">领用审批</a>
		<a id="lmb_hc_ly_sp-ysp" class="easyui-linkbutton" data-options="iconCls:'icon-ysp',plain:true">已审批领用单</a>
		<a id="lmb_hc_ly_sp-dsp" class="easyui-linkbutton" data-options="iconCls:'icon-dsp',plain:true">待审批计划</a>
		<a id="lmb_hc_ly_sp-xq" class="easyui-linkbutton" data-options="iconCls:'icon-xiangqing',plain:true">计划详情</a>
	</div>
		
	<div id="lmb-hc_ly_sp-win" class="easyui-window" title="审核领用单" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:800px;height:500px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="lmb-hc_ly_sp-form" method="post">	
					<table width="100%">
						<tr>
							<td>领用单编号: <a id="lmb-hclysp-lydbh" name="collarId"       class="easyui-linkbutton" data-options="plain:true,"></a></td>
							<td>领用对象: <a id="lmb-hclysp-lydx"  name="collarObjectName" class="easyui-linkbutton" data-options="plain:true"></a></td>					
							<td>申请日期: <a id="lmb-hclysp-lyrq" name="collarDate"       class="easyui-linkbutton" data-options="plain:true"></a></td>						
						</tr>
						<tr>							
							<td>领用仓库: <a id="lmb-hclysp-lyck" name="collarStorehouseName"   class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>审批人:<a id="lmb-hclysp-spr"    name="collarApprovepeopleName" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
					</table>
						
					<div style="margin: 5px;">
						<table id="lmb-hclysp-dg" class="easyui-datagrid" 
							data-options="
								iconCls: 'icon-edit',
								singleSelect: true,										
								width: '100%'						
						">			
							<thead>
								<tr>	
									<th data-options="field:'cdId',width:'25%',align:'center'">领用明细编号</th>	
									<th data-options="field:'cdCName',width:'25%',align:'center'">耗材名称</th>
									<th data-options="field:'cdBatchNum',width:'18%',align:'center'">批号</th>					
									<th data-options="field:'cdNorms',width:'18%',align:'center'">单位</th>
									<th data-options="field:'cdNum',width:'15%',align:'center'">领用数量</th>
								</tr>
							</thead>
						</table>									
					</div>									
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="lmb—hclysp-btn-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" >PASS</a>
				<a id="lmb—hclysp-btn-false" class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true">PAIL</a>
			</div>
		</div>
	</div>	
	
	<!--查看详情窗口-打印 -->
	<div id="lmb-hclyspDet-window" class="easyui-window" title="领用计划详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div id="lmb-hclyspDet-printArea" data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">			
				<form id="lmb_hclyspDet_form" method="post">
					<h1 style="text-align: center">耗材领用详情</h1>
					<table width="100%">
					
						<tr>
							<td>领用编号: <a id="lmb-hclyspDet-lybh" name="cpPlanId"     class="easyui-linkbutton" data-options="plain:true,"></a></td>
							<td>领用日期: <a id="lmb-hclyspDet-lyrq" name="cpPlanTitle"  class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>领用对象:  <a id="lmb-hclyspDet-lydx"  name="mname"        class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>领用仓库: <a id="lmb-hclyspDet-lyck" name="cpPlanDate"   class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
						<tr>
							<td>审批人:<a id="lmb-hclyspDet-spr"   name="pname" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>审批时间:<a id="lmb-hclyspDet-spsj" name="cpPlanApprovedate" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>审批状态:<a id="lmb-hclyspDet-spzt" name="cpPlanApprovedate" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>领用状态:<a id="lmb-hclyspDet-lyzt" name="cpPlanApprovedate" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
					</table>
						
					<div style="margin: 5px;">
						<table id="lmb-hclyspDet" class="easyui-datagrid" 
							data-options="
								iconCls: 'icon-edit',
								singleSelect: true,										
								width: '100%'						
						">			
							<thead>
								<tr>	
									<th data-options="field:'cdCId',width:'25%',align:'center'">耗材编号</th>			
									<th data-options="field:'cdCName',width:'25%',align:'center'">耗材名称</th>
									<th data-options="field:'cdBatchNum',width:'17%',align:'center'">批号</th>
									<th data-options="field:'cdNorms',width:'16%',align:'center'">单位</th>
									<th data-options="field:'cdNum',width:'16%',align:'center'">领用数量</th>
								</tr>
							</thead>
						</table>									
					</div>
				</form>				
			</div>
				
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="lmb-hclyspDet-print"  class="easyui-linkbutton" data-options="iconCls:'icon-print', plain:true">打印</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#lmb-hclyspDet-window').window('close');">取消</a>
			</div>			
		</div>
	</div>
</body>
</html>